﻿using iTextSharp.text;
using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TextDesign
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();                      //初始化
            panFind.Hide();                             //查找面板隐藏
            panFind.Enabled = false;                    //默认查找面板的方法无法进行响应交互
            panFont.Hide();                             //字体设置面板隐藏
            panFont.Enabled = false;                    //默认字体设置面板的方法无法进行响应交互
            txtMsg.Font = new System.Drawing.Font("微软雅黑", 12, Font.Style | FontStyle.Regular);      //设置默认文本字体
            txtMsg.ForeColor = Color.Black;             //设置默认字体颜色为黑色
            toolW.Checked = true;                       //设置自动换行功能默认开启
            txtMsg.WordWrap = true;
        }

        //新建功能键
        private void toolNewBuild_Click(object sender, EventArgs e)
        {
            //清空输入文本框内容
            txtMsg.Clear();
        }

        //打开文件功能键
        private void toolOpen_Click(object sender, EventArgs e)
        {
            //打开文件
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "选择要传的文件";
            ofd.InitialDirectory = @"C:\Users\Administrator\Desktop";
            ofd.Filter = "文本文件|*.txt";
            ofd.ShowDialog();
            //创建字符串类型变量filepath，用于保存文件路径
            string filePath = ofd.FileName;
            if (string.IsNullOrEmpty(filePath))
            {
                MessageBox.Show("请选择文件");
                return;
            }
            //读取文件显示在文本框里
            using (FileStream fsRead = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Read))
            {
                txtMsg.Text = File.ReadAllText(filePath);                  //显示文本
            }
        }

        string filePath = "";           //用于存储接收的文件路径
        byte[] bytereceiveData;         //字节数组，由于存储接收文本信息     
        char[] charreceiveData;         //字符数组，用于存储接收文本信息

        //保存文件功能键
        private void toolSave_Click(object sender, EventArgs e)
        {
            string strRecMsg = txtMsg.Text;           //接收的文本信息
            filePath = "";
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "保存文件";
            sfd.InitialDirectory = @"C:\Users\Administrator\Desktop";
            sfd.Filter = "文本文件|*.txt";
            //如果没有选择保存文件路径就一直打开保存框
            while (true)
            {
                sfd.ShowDialog(this);
                filePath = sfd.FileName;
                if (string.IsNullOrEmpty(filePath))
                {

                    continue;
                }
                else
                {
                    break;
                }
            }
            //创建文件传输流filestream，Appdend不覆盖，create覆盖
            FileStream file = new FileStream(filePath, FileMode.Create, FileAccess.Write);
            charreceiveData = strRecMsg.ToCharArray();                 //将接收数据文本框的内容按字符传入charreceiveData数组
            bytereceiveData = new byte[charreceiveData.Length];        //将charreceiveData数组的长度赋予bytereceiveData数组
            Encoder ec = Encoding.UTF8.GetEncoder();                   //字符编码为utf8
            ec.GetBytes(charreceiveData, 0, charreceiveData.Length, bytereceiveData, 0, true);
            if (charreceiveData == null && bytereceiveData == null)
            {
                MessageBox.Show("保存失败", "error");
            }
            else
            {
                MessageBox.Show("保存成功", "true");
            }
            file.Write(bytereceiveData, 0, bytereceiveData.Length);         //写入接收信息
            file.Flush();                                                   //关闭文件传输流
            file.Close();                                                   //关闭文件传输流   
        }

        //关闭文件功能键
        private void toolExit_Click(object sender, EventArgs e)
        {
            //创建DiaglogResult类型变量result，用于提示是否关闭窗口
            DialogResult result = MessageBox.Show("关闭窗口？","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
            if(result == DialogResult.OK)
            {
                Environment.Exit(0);
            }

        }

        //打印文件功能键
        private void toolPrint_Click(object sender, EventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();     //调用打印的实现方法
            printDialog.Document = pdText;                    
            printDialog.ShowDialog();

        }

        //打印实现方法
        private void pdText_Print(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            StringReader lineReader = null;                  //记录当前读取的位置
            Graphics g = e.Graphics;                         //获得绘图对象
            float linesPerPage = 0;                          //页面的行号
            float yPosition = 0;                             //绘制字符串的纵向位置
            int count = 0;                                   //行计数器
            float leftMargin = 1;                            //左边距
            float topMargin = 1;                             //上边距
            string line = "";                                //行字符串
            System.Drawing.Font printFont = this.txtMsg.Font;               //当前的打印字体
            SolidBrush myBrush = new SolidBrush(Color.Black);               //刷子
            linesPerPage = e.MarginBounds.Height / printFont.GetHeight(g);  //每页可打印的行数
            //逐行的循环打印一页
            while (count < linesPerPage && ((line = lineReader.ReadLine()) != null))
            {
                yPosition = topMargin + (count * printFont.GetHeight(g));
                g.DrawString(line, printFont, myBrush, leftMargin, yPosition, new StringFormat());
                count++;
            }
            if (line != null)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                // 重新初始化lineReader对象，不然使用打印预览中的打印按钮打印出来是空白页
                lineReader = new StringReader(txtMsg.Text); // 打印的文本框内容
            }
        }

        //使用pdText控件，进行页面设置
        private void PageSet_Click(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            //创建PageSetupDialog类型变量pageSetupDialog，用于设置打印页面
            PageSetupDialog pageSetupDialog = new PageSetupDialog();
            pageSetupDialog.Document = pdText;
            pageSetupDialog.ShowDialog();
        }

        //导出文件功能键
        //将记事本导出成图片jpg格式，再转换成pdf格式
        private void toolInput_Click(object sender, EventArgs e)
        {
            //GDI+                 
            this.txtMsg.Focus();
            //设置导出的jpg图片的长度和宽度
            Bitmap bmp = new Bitmap(this.Size.Width, this.Size.Height);
            this.DrawToBitmap(bmp, new System.Drawing.Rectangle(0, 0, Width, Height));
            bmp.Save(".//temp.jpg");
            //选择导出pdf的路径并导出 ITextSharp.dll插件
            string pdfpath = GetExportPDFPath();
            if (pdfpath == String.Empty)
            {
                MessageBox.Show("导出失败，请重试!!");  
                return;
            }
            else
            {
                ConvertJPGToPDF(".//temp.jpg", pdfpath);
                MessageBox.Show("导出成功!!");     
            }
        }

        //先定义一个获取需要保存pdf的路径的函数
        public static string GetExportPDFPath()
        {
            //创建字符串类型变量filename，用于设置保存文件名
            string filename = System.DateTime.Now.ToString().Replace("/", "").Replace(":", "") + "XXX";
            //设置文件后缀名
            var exportFileName = filename + ".pdf";
            //创建字符串类型saveFileDialog，用于实现保存文件
            var saveFileDialog = new SaveFileDialog { FileName = exportFileName };            
            saveFileDialog.Filter = "导出数据文件(*.pdf)|*.pdf";
            saveFileDialog.FilterIndex = 0;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.Title = "导出数据文件";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                return saveFileDialog.FileName;
            }
            else
            {
                return String.Empty;
            }
        }

        //定义jpg图片转pdf的函数
        public void ConvertJPGToPDF(string jpgfile, string pdf)
        {
            //设置导出的pdf页面的长度和宽度
            iTextSharp.text.Rectangle PageSize = new iTextSharp.text.Rectangle(this.Width, this.Height);
            var document = new iTextSharp.text.Document(PageSize, 25, 25, 25, 25);
            //设置保存导出后的pdf文件路径
            using (var stream = new FileStream(pdf, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                //导出pdf格式文件
                PdfWriter.GetInstance(document, stream);
                document.Open();
                using (var imageStream = new FileStream(jpgfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    //设置导出的字体格式
                    BaseFont bfChinese = BaseFont.CreateFont("C://windows//fonts//simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                    iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));
                    document.Add(new Paragraph(this.txtMsg.Text, fontChinese));
                    var image = iTextSharp.text.Image.GetInstance(imageStream);
                    if (image.Height > PageSize.Height - 25)
                    {
                        image.ScaleToFit(PageSize.Width - 25, PageSize.Height - 25);
                    }
                    else if (image.Width > PageSize.Width - 25)
                    {
                        image.ScaleToFit(PageSize.Width - 25, PageSize.Height - 25);
                    }
                    image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
                    document.Add(image);
                }
                document.Close();
            }
        }

        //撤销功能键
        private void toolZ_Click(object sender, EventArgs e)
        {
            // 决定文本框最后的操作是否能撤销 
            if (txtMsg.CanUndo == true)
            {
                // 撤销最后的操作
                txtMsg.Undo();
                // 从该文本框的撤消缓冲区中清除关于最近操作的信息。
                txtMsg.ClearUndo();
            }
        }

        //复制功能键
        private void toolCopy_Click(object sender, EventArgs e)
        {
            //确保文本在文本框中已经选定 
            if (txtMsg.SelectionLength > 0)
            // 复制文本到剪贴板
            txtMsg.Copy();
        }

        //粘贴功能键
        private void toolPaste_Click(object sender, EventArgs e)
        {
            // 判断剪贴板中是否有文本
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
            {
                // 判断文本框中是否有文本选定了
                if (txtMsg.SelectionLength > 0)
                {
                    // 询问是否覆盖选定的文本
                    if (MessageBox.Show("你想覆盖选定的文本吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
                        // 移动选定文本的位置，即之前选定文本的起始+选定文本的长度
                        txtMsg.SelectionStart = txtMsg.SelectionStart + txtMsg.SelectionLength;
                }
                // 将剪贴板中的文本粘贴至文本框
                txtMsg.Paste();
            }
        }

        //获取或设置查找起始位置
        static int Index = 0;
        //查找到的字符串数量
        static int count = 0;
        //查找字符是否变更
        static string strE = string.Empty;
        //记录原始光标位置
        static int MemoIndex = -1;
        //过度字符串变量
        static string str = string.Empty;
        //实例化富文本
        static RichTextBox r = new RichTextBox();

        //查找功能键
        private void toolFind_Click(object sender, EventArgs e)
        {
            panFind.Show();                         //当点击查找功能时，才显示查找面板
            panFind.Enabled = true;                 //同时查找方法才可以响应交互
        }

        //向上查找按钮
        private void FindUp_Click(object sender, EventArgs e)
        {
            findUp(txtMsg, txtFind.Text);           //调用向上查找的实现方法
        }

        //向上查找的实现方法
        public static void findUp(RichTextBox rtxt, string str)
        {
            //确定查找字符
            if (strE != str)
            {
                rtxt.SelectionStart = rtxt.Text.Length;
                strE = str;
            }
            //记录查找的字符的初始位置
            Index = rtxt.SelectionStart;
            //查找原文本中查找字符出现的次数
            Index = rtxt.Find(str, 0, Index, RichTextBoxFinds.Reverse);
            //如果次数大于0，则逐个选中
            if (Index >= 0)
            {
                rtxt.SelectionStart = Index;
                rtxt.SelectionLength = str.Length;
                count++;
                rtxt.Focus();
                //同时设置查找出的字符的颜色
                myColor(rtxt);                  
                if (Index <= 0)
                {
                    seeks(str);
                    count = 0;
                }
            }
            else if (Index < 0)
            {
                seeks(str);
                count = 0;
            }
        }

        //向下查找按钮
        private void FindDown_Click(object sender, EventArgs e)
        {
            findDown(txtMsg, txtFind.Text);           //调用向下查找的实现方法
        }

        //向下查找的实现方法
        public static void findDown(RichTextBox rtxt, string FindStr)
        {
            //查找原文本中查找字符出现的次数
            Index = rtxt.Find(FindStr, Index, RichTextBoxFinds.MatchCase);
            if (Index < 0 || Index > rtxt.Text.Length)
            {
                seeks(FindStr);
                count = 0;
                Index = 0;
            }
            else
            {
                rtxt.Select(Index, FindStr.Length);
                //设置查找出的字体的颜色
                myColor(rtxt);
                //指向下一个字符
                Index += FindStr.Length;
                rtxt.Focus();
            }
        }

        //查找到的字体颜色设置
        private static void myColor(RichTextBox rtxt)
        {
            //设置查找出的字体的颜色是黑色
            rtxt.SelectionColor = Color.Black;
        }

        //显示查找结果
        public static void seeks(string str)
        {
            if (count != 0)
                MessageBox.Show(string.Format("已查找完毕,共〖{0}〗个 \"{1}\"!", count, str), "查找结果 - 提示!!");
            else MessageBox.Show(string.Format("没有查找到 \"{0}\"!", str), "查找 - 提示!");
        }

        //关闭查找面板
        private void btnClose_Click(object sender, EventArgs e)
        {
            panFind.Hide();                             //查找面板隐藏
            panFind.Enabled = false;                    //同时设置面板方法无法响应交互
        }

        //替换功能键
        private void toolReplace_Click(object sender, EventArgs e)
        {
            panFind.Show();                             //查找面板显示
            panFind.Enabled = true;                     //设置面板方法可以进行响应交互
        }
        
        //替换
        private void btnReplace_Click(Object sender,EventArgs e)
        {
            Replace(txtMsg, txtFind.Text, txtReplace.Text);     //调用单个替换实现方法
        }

        //单个替换的实现方法
        private void Replace(RichTextBox rtxt, string FindString, string ReplString)
        {
            //创建字符串类型变量txtSt，用于存储选择的文本
            string txtSt = rtxt.SelectedText;
            //当原文本中有查找的文本时，开始替换
            if (FindString.Equals(txtSt))
            {
                int fs = FindString.Length;
                int rs = ReplString.Length;
                int cs = fs - rs;
                rtxt.SelectionLength = FindString.Length;       //设置原文本选中的字符的长度为查找文本的字符长度
                rtxt.SelectionColor = Color.Coral;              //设置选中字体的颜色
                rtxt.SelectedText = ReplString;                 //textBox2中放要替换的字符 
                rtxt.Focus();
                MemoIndex = -1;         
                rtxt.SelectionStart += cs;                      //如果原文本中还有需要替换的文本，则指向下一个
            }
            findDown(rtxt, FindString);
        }

        //全部替换按钮
        private void btnAllReplace_Click(object sender, EventArgs e)
        {
            allReplace(txtMsg, txtFind.Text, txtReplace.Text);  //调用全部替换方法
        }

        //全部替换实现方法
        private void allReplace(RichTextBox rtxt, string FindStr, string ReplStr)
        {
            //当原文本还有查找到的文本时持续替换
            while (Index >= 0 || Index <= rtxt.Text.Length)
            {
                int cot = FindStr.Length - ReplStr.Length;
                if(Index>rtxt.Text.Length)
                {
                    break;
                }
                //记录原文本还需替换的字符的长度
                Index = rtxt.Find(FindStr, Index, RichTextBoxFinds.MatchCase);       
                if (Index < 0 || Index > rtxt.Text.Length)
                {
                    DialogResult r = MessageBox.Show(string.Format("查找结束，已经为您找到{0}个结果。", count),
                      "查找结果 - 提示!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (r == DialogResult.Yes)
                    {
                        count = 0;
                    }
                    Index = 0;
                    break;
                }
                else
                {
                    rtxt.Select(Index, FindStr.Length);
                    replace(rtxt, FindStr, ReplStr);
                    Index += FindStr.Length;
                    count++;
                }
            }
        }
        private static void replace(RichTextBox rtxt, string FindString, string ReplString)
        {
            rtxt.SelectionLength = FindString.Length;
            rtxt.SelectedText = ReplString;                 //textBox2中放要替换的字符 
            Index = rtxt.SelectionStart;                    //获取或设置光标选定位置
        }

        //自动换行功能键
        private void toolW_Click(object sender, EventArgs e)
        {            
            if(toolW.Checked == true)                       //如果自动换行标志打开，此时响应的逻辑事件是关闭自动换行
            {
                txtMsg.WordWrap = false;                    //文本的自动换行功能关闭
                toolW.Checked = false;                      //同时自动换行标志关闭
            }
            else if(toolW.Checked == false)                 //如果自动换行标志关闭，此时响应的逻辑事件是打开自动换行
            {
                txtMsg.WordWrap = true;                     //文本的自动换行功能开启
                toolW.Checked = true;                       //同时自动换行标志开启
            }
        }

        //字体设置功能键
        private void toolFont_Click(object sender, EventArgs e)
        {
            panFont.Show();                     //字体设置面板显示
            panFont.Enabled = true;             //字体面板的方法可以进行交互
            
        }

        //确定功能键
        private void btnOK_Click(Object sender,EventArgs e)
        {
            fontSet(cbxFont.Text, cbxStyle.Text, cbxSize.Text, cbxColor.Text);           //设置字体样式
        }

        //设置字体的实现方法
        private void fontSet(String font,String fontStyle,String fontSize,String fontColor)
        {
            //字体设置为宋体
            if(font == "宋体")
            {            
                //字体设置为粗体
                if (fontStyle == "Bold")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为倾斜
                if (fontStyle == "倾斜")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为常规
                if (fontStyle == "常规")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("宋体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
            }
            //字体设置为仿宋
            if (font == "仿宋")
            {
                //字体设置为粗体
                if (fontStyle == "Bold")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为倾斜
                if (fontStyle == "倾斜")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为常规
                if (fontStyle == "常规")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("仿宋", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
            }
            //字体设置为黑体
            if (font == "黑体")
            {
                //字体设置为粗体
                if (fontStyle == "Bold")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为倾斜
                if (fontStyle == "倾斜")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为常规
                if (fontStyle == "常规")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("黑体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
            }
            //字体设置为楷体
            if (font == "楷体")
            {
                //字体设置为粗体
                if (fontStyle == "Bold")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为倾斜
                if (fontStyle == "倾斜")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为常规
                if (fontStyle == "常规")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("楷体", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
            }
            //字体设置为微软雅黑
            if (font == "微软雅黑")
            {
                //字体设置为粗体
                if (fontStyle == "Bold")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Bold);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为倾斜
                if (fontStyle == "倾斜")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Italic);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
                //字体设置为常规
                if (fontStyle == "常规")
                {
                    //字体设置为5pt
                    if (fontSize == "5")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 5, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为10pt
                    if (fontSize == "10")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 10, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                    //字体设置为15pt
                    if (fontSize == "15")
                    {
                        //设置字体颜色为黄色
                        if (fontColor == "黄色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Yellow;
                        }
                        //设置字体颜色为黑色
                        if (fontColor == "黑色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Black;
                        }
                        //设置字体颜色为绿色
                        if (fontColor == "绿色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Green;
                        }
                        //设置字体颜色为红色
                        if (fontColor == "红色")
                        {
                            txtMsg.Font = new System.Drawing.Font("微软雅黑", 15, Font.Style | FontStyle.Regular);
                            txtMsg.ForeColor = Color.Red;
                        }
                    }
                }
            }
        }

        //取消功能键
        private void btnNO_Click(Object sender, EventArgs e)
        {
            panFont.Hide();                 //字体设置面板隐藏
            panFont.Enabled = false;        
        }
    }
}
